// 维修订单接口文档
import { api } from 'boot/axios'

/** 新增用户数：
 * maintenanceProject	String	是	维修项目
 * faultContent	String	是	故障内容
 * maintenanceHouseNumber	String	是	维修房屋编号
 * maintenanceWorkerId	Long	是	维修工人ID
 * maintenanceName	String	是	维修人姓名
 * cost	BigDecimal	否	维修费用
 * videos	String	否	视频链接
 * images	String	否	图片链接
 * maintenanceVoucher	String	否	维修凭证
 * status	String	否	维修状态（如待处理、已完成）
 **/
export interface IRepairOrderParam {
  maintenanceProject: string
  faultContent: string
  maintenanceHouseNumber: string
  maintenanceWorkerId: number
  maintenanceName: string
  cost: number
  videos: string
  images: string
  maintenanceVoucher: string
  status: string
}
export type IEditRepairOrderParam = Partial<IRepairOrderParam> & {
  maintenanceOrderId: number
}

const REPAIR_ORDER_URL = '/house/maintenance-order'
const REPAIR_ORDER_PAGE_URL = '/house/maintenance-order/page'
const REPAIR_ORDER_LIST_URL = '/house/maintenance-order/list'

// RepairOrder
export function addRepairOrder(data: IRepairOrderParam) {
  return api.post(REPAIR_ORDER_URL, data)
}
export function editRepairOrder(data: IEditRepairOrderParam) {
  return api.put(REPAIR_ORDER_URL, data)
}
export function removeRepairOrder(id: number) {
  return api.delete(`${REPAIR_ORDER_URL}/${id}`)
}
export function getRepairOrderById(id: number) {
  return api.get(`${REPAIR_ORDER_URL}/${id}`)
}
export function getRepairOrderList() {
  return api.get(REPAIR_ORDER_LIST_URL)
}
export interface IRepairOrderParams {
  pageNum: number
  pageSize: number
  maintenanceProject?: string
  status?: string
}
export function getRepairOrderPageList(oArg: IRepairOrderParams) {
  const params: IRepairOrderParams = { pageNum: oArg.pageNum || 1, pageSize: oArg.pageSize || 10 }
  if (oArg.status) {
    params.status = oArg.status
  }
  if (oArg.maintenanceProject) {
    params.maintenanceProject = oArg.maintenanceProject
  }
  return api.get(REPAIR_ORDER_PAGE_URL, { params })
}
